; (() => {


  const _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
  const _p = "W5D80NFZHAYB8EUI2T649RT2MNRMVE2O";
  function _u_e(e) {
    if (null == e)
      return null;
    e = e.replace(/\r\n/g, "\n");
    for (var t = "", n = 0; n < e.length; n++) {
      var r = e.charCodeAt(n);
      r < 128 ? t += String.fromCharCode(r) : r > 127 && r < 2048 ? (t += String.fromCharCode(r >> 6 | 192),
        t += String.fromCharCode(63 & r | 128)) : (t += String.fromCharCode(r >> 12 | 224),
          t += String.fromCharCode(r >> 6 & 63 | 128),
          t += String.fromCharCode(63 & r | 128))
    }
    return t
  }

  function e2(e) {
    if (null == (e = _u_e(e)))
      return null;
    for (var t = "", n = 0; n < e.length; n++) {
      var r = _p.charCodeAt(n % _p.length);
      t += String.fromCharCode(e.charCodeAt(n) ^ r)
    }
    return t
  }

  function e1(e) {
    if (null == e)
      return null;
    for (var t, n, r, o, i, a, u, c = "", l = 0; l < e.length;)
      o = (t = e.charCodeAt(l++)) >> 2,
        i = (3 & t) << 4 | (n = e.charCodeAt(l++)) >> 4,
        a = (15 & n) << 2 | (r = e.charCodeAt(l++)) >> 6,
        u = 63 & r,
        isNaN(n) ? a = u = 64 : isNaN(r) && (u = 64),
        c = c + _keyStr.charAt(o) + _keyStr.charAt(i) + _keyStr.charAt(a) + _keyStr.charAt(u);
    return c
  }

  function sig(e) {
    return md5(e + _p).toUpperCase()
  }
  function d1(e) {
    var t, n, r, o, i, a, u = "", c = 0;
    for (e = e.replace(/[^A-Za-z0-9\+\/\=]/g, ""); c < e.length;)
      t = _keyStr.indexOf(e.charAt(c++)) << 2 | (o = _keyStr.indexOf(e.charAt(c++))) >> 4,
        n = (15 & o) << 4 | (i = _keyStr.indexOf(e.charAt(c++))) >> 2,
        r = (3 & i) << 6 | (a = _keyStr.indexOf(e.charAt(c++))),
        u += String.fromCharCode(t),
        64 != i && (u += String.fromCharCode(n)),
        64 != a && (u += String.fromCharCode(r));
    return u
  }
  function d2(e) {
    for (var t = "", n = 0; n < e.length; n++) {
      var r = _p.charCodeAt(n % _p.length);
      t += String.fromCharCode(e.charCodeAt(n) ^ r)
    }
    return t = _u_d(t)
  }

  function _u_d(e) {
    for (var t = "", n = 0, r = 0, o = 0, i = 0; n < e.length;)
      (r = e.charCodeAt(n)) < 128 ? (t += String.fromCharCode(r),
        n++) : r > 191 && r < 224 ? (o = e.charCodeAt(n + 1),
          t += String.fromCharCode((31 & r) << 6 | 63 & o),
          n += 2) : (o = e.charCodeAt(n + 1),
            i = e.charCodeAt(n + 2),
            t += String.fromCharCode((15 & r) << 12 | (63 & o) << 6 | 63 & i),
            n += 3);
    return t
  }


  let num = 0
  const res = []
  function fetchData() {
    console.log('num', num)
    const n = {
      payload: {
        "sort": 2,
        "start": num,
        "limit": 20
      }
    }

    const t = e2(JSON.stringify(n.payload))
    const t2 = e1(t)
    const t3 = sig(t2)

    const body = JSON.stringify({
      payload: t2,
      sig: t3,
      v: 1

    })

    fetch("https://www.xiniudata.com/api2/service/x_service/person_industry_list/list_industries_by_sort", {
      "headers": {
        "accept": "application/json",
        "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
        "cache-control": "no-cache",
        "content-type": "application/json",
        "pragma": "no-cache",
        "priority": "u=1, i",
        "sec-ch-ua": "\"Google Chrome\";v=\"125\", \"Chromium\";v=\"125\", \"Not.A/Brand\";v=\"24\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"macOS\"",
        "sec-fetch-dest": "empty",
        "sec-fetch-mode": "cors",
        "sec-fetch-site": "same-origin"
      },
      "referrer": "https://www.xiniudata.com/industry/newest?from=data",
      "referrerPolicy": "strict-origin-when-cross-origin",
      "body": body,
      "method": "POST",
      "mode": "cors",
      "credentials": "include"
    }).then(r => r.json())
      .then(r => {
        const d = r.d
        const t = JSON.parse(d2(d1(d)))
        res.push(...t.list)
        num++
        if (num > 5) downloadText('犀牛数据', JSON.stringify(res))
        else fetchData()
      })

  }


  function downloadText(fileName, text) {
    const url = window.URL || window.webkitURL || window;
    const blob = new Blob([text]);
    const saveLink = document.createElement("a");
    saveLink.href = url.createObjectURL(blob);
    // 设置 download 属性
    saveLink.download = fileName + '.json';;
    saveLink.click();
    url.revokeObjectURL(saveLink.href);
    saveLink?.remove()
  }

  fetchData()




})();